package com.androidsocketd.productdaobase;

import android.arch.persistence.room.Database;
import android.arch.persistence.room.Room;
import android.arch.persistence.room.RoomDatabase;
import android.content.Context;

import com.androidsocketd.bean.Classes;
import com.androidsocketd.bean.MachineNumber;
import com.androidsocketd.bean.Post;
import com.androidsocketd.bean.Product;
import com.androidsocketd.bean.ProductDetail;
import com.androidsocketd.bean.Staff;
import com.androidsocketd.bean.Team;
import com.androidsocketd.dao.ClassesDao;
import com.androidsocketd.dao.MachineNumDao;
import com.androidsocketd.dao.PostDao;
import com.androidsocketd.dao.ProductDao;
import com.androidsocketd.dao.ProductDetailDao;
import com.androidsocketd.dao.StaffDao;
import com.androidsocketd.dao.TeamDao;


@Database(entities = { Product.class,ProductDetail.class ,Classes.class, Team.class, Staff.class, Post.class,MachineNumber.class}, version = 11,exportSchema = false)
public abstract class ProductDatabase extends RoomDatabase {

    private static final String DB_NAME = "kedaBase.db";
    private static volatile ProductDatabase instance;

    public static synchronized ProductDatabase getInstance(Context context) {
        if (instance == null) {
            instance = create(context);
        }
        return instance;
    }

    private static ProductDatabase create(final Context context) {
        return Room.databaseBuilder(
                context,
                ProductDatabase.class,
                DB_NAME).
                fallbackToDestructiveMigration().build();
    }

    public abstract ProductDao getProductDao();

    public abstract ProductDetailDao getProductDetailDao();

    public abstract ClassesDao getClassesDao();

    public abstract TeamDao getTeamDao();

    public abstract StaffDao getStaffDao();

    public abstract PostDao getPostDao();

    public abstract MachineNumDao getMachineNumDao();




}